﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html class="loginHtml">
<head>
    <meta charset="utf-8">
    <title>登录-代码文件后台管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="icon" href="favicon.ico">
    <link rel="stylesheet" href="~/Content/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="~/Content/public.css" media="all" />
</head>
<body class="loginBody">
    <form class="layui-form">
        <div class="login_face"><img src="~/Content/images/face.jpg" class="userAvatar"></div>

        <div class="layui-form-item input-item">
            <label>账号/手机/邮箱</label>
            <input type="text" placeholder="请输入账号/手机/邮箱" autocomplete="off" class="layui-input" lay-verify="required" name="username">
        </div>

        <div class="layui-form-item input-item">
            <label>密码</label>
            <input type="password" placeholder="请输入密码" autocomplete="off" class="layui-input" lay-verify="required" name="pwd">
        </div>

        <div class="layui-form-item">
            <button class="layui-btn layui-block" lay-filter="login" lay-submit>登录</button>
        </div>
   </form>
    <script type="text/javascript" src="~/Content/layui/layui.js"></script>
    <script>
        layui.use(['form', 'layer', 'jquery'], function () {
            var form = layui.form,
                layer = parent.layer === undefined ? layui.layer : top.layer
            $ = layui.jquery;
            //登录按钮
            form.on("submit(login)", function (data) {
                $.post("/user/login", data.field, function (res) {
                    if (res.code == 0) {
                        layer.msg("登录成功", { time: 1500, icon: 6 }, function () {
                            window.location.href = "/home/index";
                        });
                    } else {
                        layer.msg("用户名或密码错误", { time: 1500, icon: 5 });
                    }
                });
                return false;
            });

            //表单输入效果
            $(".loginBody .input-item").click(function (e) {
                e.stopPropagation();
                $(this).addClass("layui-input-focus").find(".layui-input").focus();
            });
            $(".loginBody .layui-form-item .layui-input").focus(function () {
                $(this).parent().addClass("layui-input-focus");
            });
            $(".loginBody .layui-form-item .layui-input").blur(function () {
                $(this).parent().removeClass("layui-input-focus");
                if ($(this).val() != '') {
                    $(this).parent().addClass("layui-input-active");
                } else {
                    $(this).parent().removeClass("layui-input-active");
                }
            })
        })

    </script>
</body>
</html>